package com.chen.bq;

import java.util.concurrent.ArrayBlockingQueue;

// 这组API，有返回值，不抛出异常
public class BlockingQueueTest2 {
    public static void main(String[] args) {

        // 队列大小3
        ArrayBlockingQueue<String> blockingQueue = new ArrayBlockingQueue<>(3);
        // 添加
        System.out.println(blockingQueue.offer("a"));
        System.out.println(blockingQueue.offer("b"));
        System.out.println(blockingQueue.offer("c"));
        // false
        // System.out.println(blockingQueue.offer("d"));
        // 查看队首元素
        System.out.println(blockingQueue.peek());

        System.out.println("=============");

        System.out.println(blockingQueue.poll());
        System.out.println(blockingQueue.poll());
        System.out.println(blockingQueue.poll());
        // null
        // System.out.println(blockingQueue.poll());

    }
}
